#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int sort_by_int(const void* p1, const void* p2)
{
	return *(int*)p1 - *(int*)p2;
}
void print(int* arr,int sz)
{
	int i;
	for (i = 0; i < sz; i++)
	{
		printf("%d ", arr[i]);
	}
void swap(char* buf1, char* buf2, int num)
{
	char tmp;
	int i;
	for (i = 0; i < num; i++)
	{
		tmp = *buf1;
		*buf1 = *buf2;
		*buf2 = tmp;
		buf1++;
		buf2++;
	}
}
void my_qsort(void* base, int num, int size, int(*cmp)(const void* p1, const void* p2))
{
	int i, j, k;
	char tmp;
	for (i = 0; i < num - 1; i++)
	{
		for (j = 0; j < num - 1 - i; j++)
		{
			if (cmp((char*)base + size * j, (char*)base + (j + 1) * size) > 0)
			{
				swap((char*)base + size * j, (char*)base + (j + 1) * size, size);
			}
		}
	}
}
int main()
{
	int arr[10] = { 9,8,7,6,5,4,3,2,1,0 };
	int sz = sizeof(arr) / sizeof(arr[0]);
	my_qsort(arr, sz, sizeof(arr[0]), sort_by_int);
	print(arr, sz);
	return 0;
}